#!/usr/bin/env python
# -*- coding: utf-8 -*-
import multiprocessing
import time

from multiprocessing import Process, Queue, set_start_method

event = multiprocessing.Event()

def xiao_fan(event):
    print('小贩：生产...')
    print('小贩：售卖...')
    # time.sleep(1)
    print('小贩：等待就餐')
    event.set()
    event.clear()
    event.wait()
    print('小贩：谢谢光临')
    event.set()
    event.clear()


def gu_ke(event):
    print('顾客：准备买早餐')
    event.set()
    event.clear()
    event.wait()
    print('顾客：买到早餐')
    print('顾客：享受美食')
    # time.sleep(2)
    print('顾客：付款，真好吃...')
    event.set()
    event.clear()


if __name__ == '__main__':
    set_start_method('fork', True)

    # 创建进程
    xf = multiprocessing.Process(target=xiao_fan, args=(event,))
    gk = multiprocessing.Process(target=gu_ke, args=(event, ))
    # 启动进程

    gk.start()
    xf.start()

    # time.sleep(2)
